<!DOCTYPE html>
<html class="login-bg">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="${ctx}/static/login/css/bootstrap/bootstrap.css" rel="stylesheet">
    <link href="${ctx}/static/login/css/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctx}/static/login/css/compiled/layout.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/static/login/css/compiled/elements.css">
    <link rel="stylesheet" href="${ctx}/static/login/css/compiled/signin.css" type="text/css" media="screen" />
     <style type="text/css">
         .Validform_error, input.error, select.error {
			    background-color: #fbe2e2;
			    border-color: #c66161;
			    color: #c00;
			}
     </style>
     <title>${sysName!}</title>
</head>
<body>

    <div class="login-wrapper">
        <a href="index.html">
            <img class="logo" src="${ctx}/static/login/logo.png" style="width: 20%;height: 20%;">
        </a>
      <form class="form form-horizontal"  method="post">
        <div class="box">
            <div class="content-wrap">
               <h6 id = "msg">登录</h6>
                <input id="account" name="account" type="text" placeholder="账户" class="form-control input -text">
                <input id="password" name="password" type="password" placeholder="密码" class="form-control input -text">
                <input name="" type="submit" class="btn-glow primary login" value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
            </div>
        </div>
        </form>
    </div>

	<!-- scripts -->
    <script type="text/javascript" src="${ctx}/static/lib/jquery/1.9.1/jquery.min.js"></script> 
    <script type="text/javascript" src="${ctx}/static/lib/jquery.form/3.46.0/jquery.form.js"></script>
	<script type="text/javascript" src="${ctx}/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
	<script type="text/javascript" src="${ctx}/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
	<script type="text/javascript" src="${ctx}/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript">
	     
	     $('input').focus(function(){
	    	 $(this).removeClass('error');
	     });
	
		$(".form").validate({
			rules:{
				"account":{
					required:true,
				},
				"password":{
					required:true
				}
			},
			messages:{
				"account":{
					required:"请输入用户名",
				},
				"password":{
					required:"请输入密码"
				}
			}, 
		    //重写错误显示消息方法,以alert方式弹出错误消息   
		   showErrors : function(errorMap, errorList) {  
		    var msg = null;
		    //console.log(errorList[0].element);
		    if(errorList.length > 0){
		    	msg = errorList[0].message;
		    }
		    
		    if (msg != "" && msg != null)  {
		    	$(errorList[0].element).addClass('error');
		    }
		    	
		   }, 
		   onkeyup:false,
		   onfocusout : false,
		   submitHandler:function(form){
				$(form).ajaxSubmit({
			        type:"post",
			        url:"${ctx}/login",
			        //beforeSubmit: showRequest,
			        success: function(data){
			        	 if(data.code == "-4"){
			        		 $("#msg").css("color","red");
			        		 $("#msg").html(data.msg);
			        	 }else if(data.code == "0"){
			        		 window.location.href = "${ctx}/toIndex";
			        	 }
			        	 
			        	
			        }
			      });
			}
		});
		
		
		</script>
</body>
</html>
